<div class="ui_table">
    <table cellpadding="0" cellspacing="0" width="100%">
        <tr>
            <td style="vertical-align:top">
                <div id="cc" class="easyui-calendar" data-options="onSelect:findUsageLog"></div>
            </td>
            <td align="center">
                <ul id="log_id">
                </ul>
            </td>
        </tr>
    </table>
</div>
<div style="top:40px;position:relative">&nbsp;</div>
<div class="popup_btn" style="bottom:0px;position: absolute;left: 0px;right: 0px;">
    <button class="btn btn_border close">关闭</button>
</div>
<script>
    var dates;
    $(function () {
        var win = $('#${pid}');
        win.find('.close').click(function () {
            win.window('close');
        });
        $.post("${contextPath}/security/hdw/battery/findUsageLogCount.htm", {
            id: '${batteryId}'
        }, function (json) {
            if (json.data != '') {
                dates=json.data;
                $('#cc').calendar({
                    formatter:  function (date){
                        var queryTime = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
                        if($.inArray(queryTime, dates)!=-1){
                            return '<div style="color: red;font-weight:bolder;">' + date.getDate() + '</div>';
                        }
                        return '<div style="color: black;">' + date.getDate() + '</div>';
                    }
                });
            }
        }, 'json');
        findUsageLog(new Date());
    })

    function findUsageLog(date) {
        var queryTime = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
        $.post("${contextPath}/security/hdw/battery/findUsageLog.htm", {
            id: '${batteryId}',
            date: queryTime
        }, function (json) {
            var html = '';
            $("#log_id").empty();
            if (json.data != '') {
                $.each(json.data, function (index, item) {
                    if (item != null) {
                        html += "<li>" + item + "</li>";
                    }
                });
            }
            $("#log_id").append(html);
        }, 'json');
    }
</script>


